<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>

<body>
    <h1>Hello</h1>
    <button onclick="readCard()">readCard</button>
</body>

<script>
   
    var nxmi = require('./build/Release/nxmi.node')
    console.log(nxmi);
    console.log(nxmi.hello());

    function readCard() {

        console.log('xxx');
        const data = {
            yljgdm: '00000002',
            ip: '127.0.0.1',
            biztype: 'J2',
            data: '<?xml version="1.0" encoding="GBK"?><DATA> <HEAD> <VER>01.01</VER> <APP>J2</APP> <WorkDate>20181116</WorkDate> <Reserve></Reserve> <ErrCode></ErrCode> <ErrDetail></ErrDetail> </HEAD> <MSG> <HEAD> <YLJGDM>00000002</YLJGDM><JYRQ>20181116000000</JYRQ><MZZYBZ>0</MZZYBZ><ZXBXBZ>0</ZXBXBZ><ZHCXBZ>1</ZHCXBZ><DKXXBZ>1</DKXXBZ><PWD>1</PWD></HEAD></MSG></DATA>'
        }

        const params = {
            'functionname': 'bizbuss',
            'params': {
                'hid': data.yljgdm,
                'biztype': data.biztype,
                'ip': data.ip,
                'indata': data.data
            }
        }

        const outdata = (nxmi.invoke(JSON.stringify(params))); // 'hello world'

        console.log(outdata);
        var b = new Buffer.from(outdata, 'base64')
        var s = b.toString();
        console.log(s);
        alert(s)
    }
</script>

</html>